//
//  UIBarButtonItem+Extension.swift
//  daoge_sineweibo
//
//  Created by 伍禄林 on 16/9/27.
//  Copyright © 2016年 伍禄林. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    ///
    ///
    /// - parameter title:    标题
    /// - parameter fontSize: 字体大小  默认16
    /// - parameter target:
    /// - parameter action:   
    ///   parameter isBack: true为反回按钮
    /// - returns: <#return value description#>
    convenience init(title: String, fontSize:CGFloat = 16,target: AnyObject,action: Selector, isBack: Bool = false) {
        
        let btn: UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.gray, highlightedColor: UIColor.orange)
        
        if(isBack) {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named: imageName), for: .normal)
            btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView:btn)
        
//        guard let btn = UIButton.cz_textButton("下一个", fontSize: 16, normalColor: UIColor.gray, highlightedColor: UIColor.orange) else  {
//            return
//        }
//        btn.addTarget(self, action: #selector(showNext), for: .touchUpInside)
        
    }
    
}
